package id.co.smltech.servo.project.utils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Properties;

import javax.ejb.Stateless;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

@Stateless
public class SystemConfiguration {

	private String dirUploadActivityTracking = "";

	public String getDirUploadActivityTracking() {
		return dirUploadActivityTracking;
	}

	public void setDirUploadActivityTracking(String dirUploadActivityTracking) {
		this.dirUploadActivityTracking = dirUploadActivityTracking;
	}

	public void init(){

		Properties properties = new Properties();
		InputStream inputStream = null;
		
		try{
						
			inputStream = new FileInputStream("D:\\Work\\Activity Tracking\\config");
			System.out.println("inputStream : "+inputStream);
			properties.load(inputStream);
			
			this.setDirUploadActivityTracking(properties.getProperty("DIR_UPLOAD_ACTIVITY_TRACKING"));	
			inputStream.close();
		}
		catch(Exception e){
			e.printStackTrace();
		}
		finally{
			if(inputStream != null){
				try{
					inputStream.close();
				}
				catch(Exception e){
					e.printStackTrace();
				}
			}
		}
	}
	
	public String getOs(){
		
		String ret = "";
		
		try{
			String OS = System.getProperty("os.name").toLowerCase();
			
			if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0 || OS.indexOf("sunos") >= 0 || OS.indexOf("mac") >= 0 )
				ret = "unix";
			else if(OS.indexOf("win") >= 0)
				ret = "windows";
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
		return ret;
	}
	
//	public static void main(String[] args){
//		SystemConfiguration systemConfiguration = new SystemConfiguration();
//		systemConfiguration.init();
//		systemConfiguration.createFileExcelSims(systemConfiguration.getDirFileExportSims());
//	}
}
